package com.sky.mapper.user;

import com.sky.pojo.Orders;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface UserOrderMapper {
    /**
     * 插入订单数据
     * @param orders
     */
    void insert(Orders orders);

    @Select("select * from orders where order_time<#{time} and status=1")
    List<Orders> getCheckPayStatusOrders(LocalDateTime time);

    @Update("update orders set status=#{status},pay_status=#{payStatus} where id=#{id}")
    int updateOrderPaySuccess(Orders orders);

    @Update("update orders set status=#{status},pay_status=#{payStatus},cancel_time=#{cancelTime},cancel_reason=#{cancelReason} where id=#{id}")
    int cancelOrder(Orders orders);

    /**
     * 根据订单号查询订单
     * @param mun
     * @return
     */
    @Select("select * from orders where number=#{mun}")
    Orders getByNumber(String mun);

    /**
     * 根据订单id查询订单
     * @param orderId
     * @return
     */
    @Select("select * from orders where id=#{orderId}")
    Orders getByOrderId(Long orderId);
}
